package com.lyx.testmap;

import com.lyx.entity.Student;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class TestMap {


    public static void main(String[] args) {


        HashMap hashMap = new HashMap();

        hashMap.put("us","美国");
        hashMap.put("zh","中国");
        hashMap.put("uk","英国");
        hashMap.get("uk");

        HashMap<String,Student> hashMap2 = new HashMap<String, Student>();

        Student student1 = new Student(1,"张三",16,90.3);
        Student student2 = new Student(9,"李四",16,89.5);
        Student student3 = new Student(8,"老六",16,55.0);
        Student student4 = new Student(4,"王五",16,80.0);
        Student student5 = new Student(3,"老六",16,55.0);
        Student student6 = new Student(6,"老七",26,55.0);

        hashMap2.put(student6.getName(),student6);
        hashMap2.put(student1.getName(),student1);
        hashMap2.put(student2.getName(),student2);
        hashMap2.put(student4.getName(),student4);
        hashMap2.put(student3.getName(),student3);

        for(Map.Entry<String,Student> set :hashMap2.entrySet()){
            System.out.println(set.getKey()+"===="+set.getValue());
        }

        //hashMap2.put(student5.getId(),student5);
//        Iterator iterator2 = hashMap2.entrySet().iterator();
//        while (iterator2.hasNext()){
//            System.out.println(iterator2.next());
//        }


        Iterator iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
